﻿//using Luna小店.Utils;
using Jd.Api;
using Jd.Api.Request;
using Jd.Api.Response;
using Newtonsoft.Json.Linq;
using System;
using System.Data;

namespace Luna小店.service
{
    /// <summary>
    /// 快递服务接口
    /// </summary>
    public class 快递Service
    {
        private String url = "https://api.jd.com/routerjson";
        private String appkey = "AE6591FF12BC8D7E5D507DC77D23590F";
        private String appsecret = "6fd314835079465a83ecfcd76e4283b6";
        private String Token = "2290558376264c4cbf72587b69e03446ji5m";
        private String customerCode = "024K708576";

        //public DataRow get交易单号信息(String QR_OTHER14)
        //{
        //    String sql = "SELECT\n" +
        //        "	QR_NAME ,\n" +
        //        "	QR_OTHER26 ,\n" +
        //        "	QR_OTHER27 ,\n" +
        //        "	concat( QR_OTHER28, QR_OTHER29, QR_OTHER30, QR_OTHER31 ) AS Address,\n" +
        //        "	QR_OTHER32  \n" +
        //        "FROM\n" +
        //        "	a_bar_code_p \n" +
        //        "WHERE\n" +
        //        "	QR_OTHER14 = \"" + QR_OTHER14 + "\"";

        //    return SQLerp.GetDataRow(sql);
        //}

        /// <summary>
        /// 获取青龙运单号接口
        /// </summary>
        public String waybillcode_get()
        {
            IJdClient client = new DefaultJdClient(url, appkey, appsecret);

            EtmsWaybillcodeGetRequest req = new EtmsWaybillcodeGetRequest();

            req.preNum = "1"; 
            req.customerCode = this.customerCode; 
            req.orderType = 0;

            EtmsWaybillcodeGetResponse response = client.Execute(req, Token, DateTime.Now.ToLocalTime());
            return response.Body;
        }

    }

}







